package com.siberiadante.multiscrolldemo.adapter;


import android.content.Context;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.siberiadante.multiscrolldemo.R;
import com.siberiadante.multiscrolldemo.bean.MineQuestionBean;
import com.siberiadante.multiscrolldemo.view.MyWebView;

/**
 * @Created SiberiaDante
 * @Describe：
 * @CreateTime: 2017/12/15
 * @UpDateTime:
 * @Email: 2654828081@qq.com
 * @GitHub: https://github.com/SiberiaDante
 */

public class MineQuestionAdapter extends RecyclerArrayAdapter<MineQuestionBean>  {
    private MyWebView.OnScrollChangeListener listener;

    public MineQuestionAdapter(Context context, MyWebView.OnScrollChangeListener listener) {
        super(context);
        this.listener = listener;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new QuestionViewHolder(parent);
    }


    public class QuestionViewHolder extends BaseViewHolder<MineQuestionBean> {

        MyWebView webView;

        public QuestionViewHolder(ViewGroup parent) {
            super(parent, R.layout.item_web);
            webView = $(R.id.wb_ad);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.setOnScrollChangeListener(listener);
            webView.setWebViewClient(new WebViewClient(){
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    webView.loadUrl(url);
                    return true;
                }
            });
        }

        @Override
        public void setData(MineQuestionBean data) {
            super.setData(data);
            webView.loadUrl("http://static.fullydar.com/Finance/Finance.html");

        }
    }


}
